package com.shelpe.services.tenant.proxy;

import java.util.Date;
import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;

import lombok.Data;

@FeignClient(name="${simbaproxy.serviceID}", url="${simbaproxy.url}")
@RequestMapping(value = "/simba")
public interface CategoryClient {

	/**
	 * 获取类目信息
	 * 0表示请求所有顶级类目的信息，这时可以忽略第二个参数，1表示获取给定的类目id的详细信息，2表示获取给定类目id的所有子类目的详细信息
	 * */
	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.insight.catsinfo.get")
	public CategoryListRespone getCategory(@RequestHeader("tenantID") long userId, @RequestParam("type") int type, @RequestParam("category_id_list") String categoryIds);
	
	@Data
	public static class CategoryListRespone extends SimbaProxyBaseDto{		
		@JsonProperty("simba_insight_catsinfo_get_response")
		private CategoryListRes res;
	}
	
	@Data
	public static class CategoryListRes{		
		@JsonProperty("category_info_list")
		private CategoryList dataList;
	}
	
	@Data
	public class CategoryList {
		@JsonProperty("insight_category_info_d_t_o")
		private List<CategoryDto> categories;
	}
	
	@Data
	public static class CategoryDto{
		@JsonProperty("cat_id")
		private int categoryID;
		@JsonProperty("cat_name")
		private String name;
		@JsonProperty("cat_level")
		private int level;
		@JsonProperty("parent_cat_id")
		private int parentID;
		@JsonProperty("cat_path_id")
		private String categoryIDs;
		@JsonProperty("cat_path_name")
		private String names;
		@JsonProperty("last_sync_time")
		@JsonFormat(shape=Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
		private Date wordsUpdated;
	}
}
